package tech.aistar.mapper.center;

import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.aistar.entity.Address;
import tech.aistar.vo.AddressVo;

import java.util.List;

/**
 * Created by 23827 on 2019/9/28.
 */
public interface AddressMapper {
//    查询所有的
    @Select("select * from address")
    List<Address> findAll();

//    删除
    @Update("update address set data_flag = 0 where id = #{value}")
    void delById(Integer id);

//    添加
    void insertAddress(Address address);

//    更改
    void updateAddress(Address address);

    //通过id查
    @Select("select * from address where id = #{id}")
    Address findById(Integer id);

    //通过id改变状态
    @Select("update address set is_default = 1 where id = #{id}")
    void updateById(Integer id);

    @Select("update address set is_default = 0")
    void changeAll();

    //通过uid查询
    @Select("select * from address where user_id = #{user_id}")
    Address findByUserId(Integer user_id);

    //通过uid查找所有的地址
    @Select("select * from address where user_id = #{user_id}")
    List<Address> findAllById(Integer user_id);


}
